package com.ruoyi.web.controller.project;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.project.domain.entity.ProjectSale;
import com.ruoyi.project.domain.entity.ProjectSaleLog;
import com.ruoyi.project.domain.entity.ProjectSaleLog;
import com.ruoyi.project.service.IProjectSaleLogService;
import com.ruoyi.project.service.IProjectSaleLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;

/**
 * 配套施工Controller
 *
 * @author zzy
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/project/saleLog")
public class ProjectSalgeLogController extends BaseController {
    @Autowired
    private IProjectSaleLogService projectSaleLogService;

    /**
     * 查询配套施工列表
     */
    @GetMapping("/list")
    public List<ProjectSaleLog> list(ProjectSaleLog log) {
       return projectSaleLogService.selectProjectSaleLogList(log);
    }


    /**
     * 新增配套施工
     */
    @Log(title = "配套施工", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectSale sale) {
        return toAjax(projectSaleLogService.insertProjectSaleLog(sale));
    }

    /**
     * 获取配套施工详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(projectSaleLogService.selectProjectSaleLogById(id));
    }


    /**
     * 修改配套施工
     */
    @Log(title = "配套施工", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectSaleLog ProjectSaleLog) {
        return toAjax(projectSaleLogService.updateProjectSaleLog(ProjectSaleLog));
    }

    /**
     * 删除配套施工
     */
    @Log(title = "配套施工", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(projectSaleLogService.deleteProjectSaleLogByIds(ids));
    }
}
